// -*- coding: utf-8 -*- 
/**
 * Project: PICProcess
 *
 * @author: yanking
 * Create time: 2022-04-20 23:23
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package HistogramEqualization;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Scanner;

public class HE {


    public static void main(String[] args) throws Exception {
        boolean flag = true;
        while (flag) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("输入1均衡化，输入2退出：");
            String type = scanner.nextLine();
            if (type.equals("2")) {
                flag = false;
            } else {
                System.out.println("请输入要处理图像的路径：");
                String inputPath = scanner.nextLine();
                System.out.println("请输入处理结果的保存路径：");
                String outputPath = scanner.nextLine() + "res.jpg";
                TransF transF = new TransF();
                File inputFile = new File(inputPath);
                BufferedImage input = ImageIO.read(inputFile);
                BufferedImage result = transF.run(input);
                File outputFile = new File(outputPath);
                ImageIO.write(result, "JPG", outputFile);

                double[] count = transF.count;
                double[] Count = transF.Count;
                double[] NSK = transF.NSK;
                Chart chart = new Chart();
                chart.createBarChart(inputPath, count, "原图灰度值");
                chart.createBarChart(outputPath, Count, "新图灰度值");
                chart.createLineChart(outputPath, NSK);
            }
        }
    }
}


